﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System.Collections.Generic;
using ScrumTable.Common;
using ScrumTable.DL.Data.Schema.Serialization;

#endregion

namespace ScrumTable.DL.Data.Schema.ScrumTableV1
{
    /// <summary>
    /// Contains additional information about the ScrumTable protocol
    /// schema. This instance follows the singleton pattern.
    /// </summary>
    public class ScrumTableV1Schema : SchemaBase
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        /// <summary>
        /// Name for the Projects data acces object.
        /// </summary>
        public readonly ProjectSchema ProjectSchema = new ProjectSchema();

        /// <summary>
        /// Name for the Members data acces object.
        /// </summary>
        public readonly MemberSchema MemberSchema = new MemberSchema();

        /// <summary>
        /// Name for the Team data acces object.
        /// </summary>
        public readonly TeamSchema TeamSchema = new TeamSchema();

        /// <summary>
        /// Name for the Iterations data acces object.
        /// </summary>
        public readonly IterationSchema IterationSchema = new IterationSchema();

        /// <summary>
        /// Name for the UserStories data acces object.
        /// </summary>
        public readonly UserStorySchema UserStorySchema = new UserStorySchema();

        /// <summary>
        /// Name for the Tasks data acces object.
        /// </summary>
        public readonly TaskSchema TaskSchema = new TaskSchema();

        /// <summary>
        /// Name for the Bugs data acces object.
        /// </summary>
        public readonly BugSchema BugSchema = new BugSchema();

        /// <summary>
        /// Name for the Attachments data acces object.
        /// </summary>
        public readonly AttachmentSchema AttachmentSchema = new AttachmentSchema();

        /// <summary>
        /// Name for the Workflows data acces object.
        /// </summary>
        public readonly TypeSchema TypeSchema = new TypeSchema();

        /// <summary>
        /// Name for the Transitions data acces object.
        /// </summary>
        public readonly TransitionSchema TransitionSchema = new TransitionSchema();

        /// <summary>
        /// Name for the Meta data acces object.
        /// </summary>
        public readonly MetaSchema MetaSchema = new MetaSchema();

        /// <summary>
        /// Name for the Report data acces object.
        /// </summary>
        public readonly ReportSchema ReportSchema = new ReportSchema();

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        /// <summary>
        /// Gets the ScrumTable schema name.
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        /// Gets a list of legacy names of the current schema.
        /// </summary>
        public IEnumerable<string> LegacyNames { get; private set; }

        /// <summary>
        /// Gets the ScrumTable schema version.
        /// </summary>
        public string Version { get; private set; }

        /// <summary>
        /// Gets the ScrumTable driver name.
        /// </summary>
        public string Driver { get; private set; }

        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        /// <summary>
        /// Do not create instances of this class.
        /// </summary>
        /// <remarks>
        /// New versions of ScrumTable may derive from this class and build a
        /// ScrumTableV2Schema for example. The name of the root schema class
        /// must be "ScrumTable.DL.Data.Schema.[Version].[Version]Schema",
        /// "ScrumTable.DL.Data.Schema.ScrumTableV2.ScrumTableV2Schema" for
        /// example.
        /// The first argument must be of type "Serialization.SchemataRoot".
        /// </remarks>
        public ScrumTableV1Schema(SchemataRoot schemata)
        {
            PreCondition.AssertNotNull(schemata, "schemata");

            Name = schemata.Name;
            Version = schemata.Version;
            Driver = schemata.Driver;

            if (schemata.Schemata != null)
            {
                ImportSchemaData(schemata);
            }
        }

        #endregion
    }
}